package com.pubinfo.passbook.common.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.pubinfo.passbook.common.model.bo.valueAddedTax.OutParamItem;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.collections.CollectionUtils;

import java.io.Serializable;

/**
 * <p>
 * 
 * </p>
 *
 * @author xuhong
 * @since 2022-01-20
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false)
public class TSynWriteoffInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 报账单号
     */
    @TableId
    private String writeoffInstanceCode;

    /**
     * 报销金额
     */
    private String writeoffSum;

    /**
     * 报账单状态
     */
    private String status;

    /**
     * 票据类型
     */
    private String invoiceType;

    /**
     * SAP凭证号
     */
    private String sapCertificateCode;

    /**
     * 公司代码
     */
    private String sapCompayCode;

    /**
     * 凭证年度
     */
    private String year;

    /**
     * 凭证记账日期
     */
    private String ledgerDate;

    /**s
     * 判断是否已经回传（0为未回传，1为已回传）
     */
    private Boolean needFeedback;
    
    public TSynWriteoffInfo(OutParamItem outParamItem)
    {
        this.writeoffInstanceCode=outParamItem.getWriteoffInstanceCode();
        this.status=outParamItem.getStatus().toString();
        this.writeoffSum=outParamItem.getWriteoffSum();
        this.invoiceType=outParamItem.getInvoiceType();
        if(CollectionUtils.isNotEmpty(outParamItem.getCertificateTitleInfos()))
        {
            this.sapCertificateCode=outParamItem.getCertificateTitleInfos().get(0).getSapCertificateCode();
            this.year=outParamItem.getCertificateTitleInfos().get(0).getYear();
            this.sapCertificateCode=outParamItem.getCertificateTitleInfos().get(0).getSapCompayCode();
            this.ledgerDate=outParamItem.getCertificateTitleInfos().get(0).getLedgerDate();
        }
    }
}
